package com.zly.bscloud.controller;

import com.zly.bscloud.dto.GarbageDTO;
import com.zly.bscloud.service.GarbageService;
import com.zly.bscloud.utils.entity.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author zhouxiaoyu
 * @Date 2020/5/6 9:20
 * @Version 1.0
 */
@RestController
@RequestMapping("/sort")
@Api(tags = "分类接口")
@CrossOrigin
public class GarbageController {
    @Autowired
    GarbageService garbageService;

    @ApiOperation(value = "获得全部分类")
    @GetMapping("/get-sorts")
    public Result showSort(){

        List<GarbageDTO> garbageDTOList = garbageService.showSort();
        System.out.println(garbageDTOList);
        System.out.println(garbageDTOList.size());
        return Result.createSuccess(garbageDTOList);
    }

    @GetMapping("/get-sortId/{name}")
    public Result getSortIdByName(@PathVariable("name") String name){
        List<GarbageDTO> garbageDTOList = garbageService.getSortIdByName(name);
        return Result.createSuccess(garbageDTOList);
    }
}
